package com.jlcindia;

public class Lab20 {
	public static void main(String[] args) {
		ShapeUtil util=new ShapeUtil();
		util.showshapeinfo(new Square(12.0));
		System.out.println("=================");
		util.showshapeinfo(new Rectangle(12.0,10.0));
	}
}
 abstract class Shape{
	double length;
	Shape(double length){
		this.length=length;
	}
	final double getLength(){
		return this.length;
	}
	abstract double findArea();
	abstract String getType();
	static void display(){
		System.out.println("--Static dispaly in shape--");
	}
}
 
 class Square extends Shape{
	Square(double side){
		super(side);
	}
	double findArea(){
		System.out.println("**Square find Area**");
		return length*length;
	}
	double getSide(){
		return length;
	}
	String getType(){
		return "Square";
	}
	static void display(){
		System.out.println("==Static display in square==");
	}
}
 class Rectangle extends Shape{
	double width;
	Rectangle(double length,double width){
		super(length);
		this.width=width;
	}
	double findArea(){
		System.out.println("**Rectangle find Area**");
		return length*width;
	}
	String getType(){
		return "Rectangle";
	}
	double getWidth(){
		return width;
	}
	static void display(){
		System.out.println("==Static display in Rectangle==");
	}
}
 class ShapeUtil{
		public void showshapeinfo(Shape sp){
			System.out.println("\nType\t:"+sp.getType());
			System.out.println("\nLenght\t:"+sp.getLength());
			System.out.println("\nArea\t:"+sp.findArea());
			sp.display();
			Shape.display();
		//	sp.getSide();//because signature not available in super
		//	Sp.getWidth();//because signature not available in super
			System.out.println();
			if(sp instanceof Square){
				Square sq=(Square)sp;
				System.out.println("Side\t:"+sq.getSide());
				sq.display();
			}
			else if(sp instanceof Rectangle){
				Rectangle rec=(Rectangle)sp;
				rec.display();
				System.out.println("Width\t:"+rec.getWidth());
			}
		}
	}
